package com.js.purs.controller;

import com.js.purs.config.FileConfig;
import com.js.purs.service.IPurProdPlanFileService;
import com.js.purs.utils.FileUtil;
import com.js.purs.utils.StringPathUtils;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.CreateCode;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.time.LocalDate;

@RestController
@RequestMapping("/file")
public class FileController {
    @Autowired
    private FileConfig fileConfig;

    @Resource
    private IPurProdPlanFileService purProdPlanFileService;


    @PostMapping("/upload")
    public R handleFileUpload(MultipartFile file) {
        return fileConfig.ruoyiFileUpload(file);
    }

    @GetMapping("/delFiles/{filesName}")
    public AjaxResult deleteFile(@PathVariable("filesName") String filesName){
        System.out.println("Purs:filesName:"+filesName);
        return fileConfig.delFiles(filesName);
    }




}
